package com.recipefinder.service;

import java.io.IOException;
import java.util.List;

import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;
import com.recipefinder.bean.Recipe;
import com.recipefinder.util.FileTools;

public class RecipeService {
	
	public List<Recipe> getRecipeListFromJson(String recipesFile) throws IOException {
		String recipesJSON = FileTools.readFile(recipesFile);
		Gson gson = new Gson();
		List<Recipe> recipes = gson.fromJson(recipesJSON,
				new TypeToken<List<Recipe>>(){}.getType());
		return recipes;
	}
}
